home *** CD-ROM | disk | FTP | other *** search
/ Software Vault: The Games Collection 1 / software vault.zip / software vault / CDR10 / SPX20.ZIP / SPX_DOC.ZIP / SPX_INI.DOC < prev    next >
Text File  |  1993-09-15  |  5KB  |  115 lines

  1. { SPX Library Version 2.0  Copyright 1993 Scott D. Ramsay }
  2.  
  3.  SPX_INI is the customization unit.  It allows you to create and maintain
  4.  custom .INI text files for use in your programs.
  5.  
  6.  You can put comments in the file by specifying a semi-colon at the
  7.  begining of the line.  To define a value you specify a key name then
  8.  what it equals then its value.
  9.  
  10.     KeyName=[value]
  11.  
  12.  Key names are case in-sensitive.  Values and key names can be anything
  13.  other than spaces.
  14.  
  15.  Below is a sample .INI file:
  16.  
  17.      ; My Custom ini file for my sample Game
  18.      ;
  19.      Players=4
  20.      BackGroundColor=0
  21.      StartX=160
  22.      StartY=100
  23.  
  24.      ; Computer level   1-Easy  4-Hard
  25.      ComputerLevel=2
  26.  
  27.      ; High Score
  28.      HighScore=39381
  29.  
  30.  
  31. ───────────────────────────────────────────────────────────────────────────
  32. Error return codes
  33.  
  34.   The following are values that are returned after a call to each function
  35.  
  36.   ini_noerror    = 0;      { no error }
  37.   ini_notexist   = 1;      { ini file does not exist }
  38.   ini_nokeyname  = 2;      { ini file does not contain key }
  39.   ini_errorsave  = 3;      { error writing data }
  40.   ini_errorload  = 4;      { error readding data }
  41.   ini_errupdate  = 5;      { error updating ini file }
  42.  
  43. ───────────────────────────────────────────────────────────────────────────
  44. function getIniInt(fileName,keyName:string;default:integer;var returned:integer):integer;
  45.  
  46.  Get an integer value from the INI file
  47.  
  48.    FILENAME:  The file name of the ini file. If FileName does not specify
  49.               an extension, .INI is automatically added.  FileName can have
  50.               a path. If not found, it will search for the file in the
  51.               same directory as the executed program.
  52.    KEYNAME:   The keyName to to read
  53.    DEFAULT:   A default integer to return if KeyName does not exist.
  54.    RETURNED:  The returned value of the keyname
  55.  
  56.  Returns an ini return code.
  57.  
  58.  EXAMPLE:
  59.  
  60.    var
  61.      HiScore : integer;
  62.  
  63.    getIniInt('myini.ini','HighScore',0,HiScore);
  64.  
  65.  { searches for the key name HighScore, if not found the HiScore
  66.    variable is set to zero }
  67.  
  68. ───────────────────────────────────────────────────────────────────────────
  69. function getIniString(fileName,keyName,default:string;var returned:string):integer;
  70.  
  71.   Same as getIniInt. Get a string value from the INI file
  72.  
  73.    FILENAME:  The file name of the ini file. If FileName does not specify
  74.               an extension, .INI is automatically added.  FileName can have
  75.               a path. If not found, it will search for the file in the
  76.               same directory as the executed program.
  77.    KEYNAME:   The keyName to read
  78.    DEFAULT:   A default string to return if KeyName does not exist.
  79.    RETURNED:  The returned value of the keyname
  80.  
  81. ───────────────────────────────────────────────────────────────────────────
  82. function setIniInt(fileName,keyName:string;value:integer):integer;
  83.  
  84.   Set an integer value to the INI file
  85.  
  86.    FILENAME:  The file name of the ini file. If FileName does not specify
  87.               an extension, .INI is automatically added.  FileName can have
  88.               a path. If not found, it will create the INI file in the same
  89.               directory as the executed program.
  90.    KEYNAME:   The keyName to change.  If the key name does not exist in the
  91.               file, it is automatically added to the end of the file
  92.    VALUE:     The value to set to keyName
  93.  
  94. ───────────────────────────────────────────────────────────────────────────
  95. function setIniString(fileName,keyName,value:string):integer;
  96.  
  97.    Same as setIniInt. Set a string value to the INI file
  98.  
  99.    FILENAME:  The file name of the ini file. If FileName does not specify
  100.               an extension, .INI is automatically added.  FileName can have
  101.               a path. If not found, it will create the INI file in the same
  102.               directory as the executed program.
  103.    KEYNAME:   The keyName to change.  If the key name does not exist in the
  104.               file, it is automatically added to the end of the file
  105.    VALUE:     The value to set to keyName.  if value is an empty string,
  106.               then the keyName is removed from the file.
  107.  
  108. ───────────────────────────────────────────────────────────────────────────
  109.  
  110. The SPX_INI unit will save the changes when your program exits to minimize
  111.  disk access.  It maintains all key names and variables in memory so you
  112. can do multiple GetIni's and SetIni in any combination. It can also maintain
  113. multiple INI files and write to all of them to disk at the end of the
  114. program.
  115.